package com.examination.exam.service.impl;

import com.examination.domain.exam.entity.Examination;
import com.examination.domain.exam.entity.PublishExamination;
import com.examination.exam.mapper.PublishExaminationMapper;
import com.examination.exam.service.ExaminationService;
import com.examination.exam.service.PublishExaminationService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PublishExaminationServiceImpl implements PublishExaminationService {

    @Autowired
    private PublishExaminationMapper publishExaminationMapper;

    @Autowired
    private ExaminationService examinationService;

    @Override
    public void publishExamniation(String examId, boolean isQualify, List<String> qualify) {
        Examination examinationById = examinationService.getExaminationById(examId);
        PublishExamination publishExamination = new PublishExamination();
        BeanUtils.copyProperties(examinationById, publishExamination);
        publishExamination.setIsQualify(isQualify);
        publishExamination.setQualify(qualify);
        publishExaminationMapper.insert(publishExamination);
    }
}
